class Hero(object):
    def __init__(self):
        self.lif = 100
        self.atk = 10
        self.arm = 2
        self.exp = 0

    def fight(self, aim):
        save()
        print('已经自动存档~~~')
        global lev
        global ms
        while aim.lif > 0:
            aim.lif -= self.atk
            print('你挥出%s,对%s造成%d的伤害,%s还有%d生命值' % (equip['武器'], aim.name, self.atk, aim.name, aim.lif))
            if aim.lif <= 0:
                print('勇敢的%s啊，你击败了怪兽！' % heron)
                print('%s少侠，你还有%d苟且值' % (heron, self.lif))
                self.exp += aim.exp
                print('获得%d点经验值' % aim.exp)
                if lev < 10:
                    if lev < 1 + self.exp // 100:
                        lev = 1 + self.exp // 100
                        self.atk += 10 + lev*2
                        self.arm += 2 + lev*2
                        self.lif = self.lif + 10
                        print('升级成功！当前等级：%d' % lev)
                elif 10 <= lev < 20:
                    if lev < self.exp // 1000:
                        lev = self.exp // 1000
                        self.atk += 10 + lev*2
                        self.arm += 2 + lev*2
                        self.lif = self.lif + 100
                        print('升级成功！当前等级：%d' % lev)
                elif 20 <= lev < 30:
                    if lev < self.exp // 10000:
                        lev = self.exp // 10000
                        self.atk += 10 + lev*2
                        self.arm += 2 + lev*2
                        self.lif = self.lif + 100
                        print('升级成功！当前等级：%d' % lev)
                elif 30 <= lev < 40:
                    if lev < self.exp // 100000:
                        lev = self.exp // 100000
                        self.atk += 10 + lev*2
                        self.arm += 2 + lev*2
                        self.lif = self.lif + 100
                        print('升级成功！当前等级：%d' % lev)
                elif 40 <= lev < 50:
                    if lev < self.exp // 1000000:
                        lev = self.exp // 1000000
                        self.atk += 10 + lev*2
                        self.arm += 2 + lev*2
                        self.lif = self.lif + 100
                        print('升级成功！当前等级：%d' % lev)
                elif lev >= 50:
                    print('已达最大等级，杀怪将不再获得经验值~')
                rewards(random.randint(0, 2))
                break
            self.lif = self.lif + self.arm - aim.atk
            print('怪兽咬了你%d的苟且值' % (aim.atk-self.arm))
            if self.lif <= 0:
                print('苟不住了，被%s打死了……you died~~~' % aim.name)
                if ms < 1:
                    sys.exit()
                else:
                    ms -= 1
                    print('你死了，但是别怕，还有复活的机会~')
                    print('目前还有%d条命,苟且值已经恢复到满状态，继续战斗吧%s' % (ms, heron))
                    self.lif = 100*lev

    def equipa(self, equipment):
        self.arm = 2 + 2*lev + equipment.arm
        equip['护甲'] = equipment
        print('%s装备成功！防御力现在为%d' % (equipment, self.arm))

    def equipw(self, equipment):
        self.atk = 10 + 2 * lev + equipment.atk
        equip['武器'] = equipment
        print('%s装备成功！攻击力变更为%d' % (equipment, self.atk))

    def __str__(self):
        return ('当前你的苟且力：%d\n当前你的攻击力：%d\n当前你的防御力：%d\n当前等级：%d\n'%(self.lif,self.atk,self.arm,lev))
